package com.sample.livewallpaperdemo.widget;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;

import com.sample.livewallpaperdemo.R;

/**
 * Created by jtxiang on 17-7-20.
 */

public class TimeWeatherUtil {

    public static Bitmap getBitmapByNumber(Context context, int number) {
        int resourceBitmap;
        switch (number) {
            case 1:
                resourceBitmap = R.drawable.time_num_one;
                break;
            case 2:
                resourceBitmap = R.drawable.time_num_two;
                break;
            case 3:
                resourceBitmap = R.drawable.time_num_three;
                break;
            case 4:
                resourceBitmap = R.drawable.time_num_four;
                break;
            case 5:
                resourceBitmap = R.drawable.time_num_five;
                break;
            case 6:
                resourceBitmap = R.drawable.time_num_six;
                break;
            case 7:
                resourceBitmap = R.drawable.time_num_seven;
                break;
            case 8:
                resourceBitmap = R.drawable.time_num_eight;
                break;
            case 9:
                resourceBitmap = R.drawable.time_num_nine;
                break;
            default:
                resourceBitmap = R.drawable.time_num_zero;
                break;
        }
        Resources res = context.getResources();
        BitmapDrawable bmpDraw = (BitmapDrawable) res.getDrawable(resourceBitmap);
        return bmpDraw.getBitmap();
    }

    public static Bitmap getBitmapByResId(Context context, int resid) {
        Resources res = context.getResources();
        BitmapDrawable bmpDraw = (BitmapDrawable) res.getDrawable(resid);
        return bmpDraw.getBitmap();
    }
}
